package com.myacg.platform.ui.event.move;

import java.awt.Component;

import com.myacg.core.entity.Point;
import com.myacg.core.move.MoveAdapter;
import com.myacg.core.utils.MoveUtils;

/**
 * 不断朝着某个终点移动的控件
 * @author Administrator
 *
 */
public class SpringMotionToEvent extends BaseLineMoveToEvent  {
	private int speed;
	public SpringMotionToEvent(Component comp) {
		super(comp);
		speed=10;
	}
	public SpringMotionToEvent(Component comp,int speed) {
		this(comp);
		this.speed=speed;
	}
	
	protected void OutOffByRunBefor() {
		if(movePlugin.getMoveLength()>=length){
			//给予某个速度点
        	movePlugin.setF(-Math.abs(movePlugin.getF())*speed);
			 
		} 
	}
	
	protected void OutOffByRunAfter() {
		//若速度小于0就停止
		if( movePlugin.getV()<=0){
			moveEngine.pause();
			
			//重新发起反方向的运动
			if(length>10){
				moveTo(endPoint,this.initF,movePlugin.getV0());
			}
		}
	}
	 
}
